class Solution {
    public int[] searchRange(int[] nums, int target) {
        int[] arr={-1,-1};

        if(nums.length==0) return arr;


        int left=0,right=nums.length-1;
        int mid;

        while(left<right){
            mid=(right-left)/2+left;
            if(nums[mid]<target) left=mid+1;
            else right=mid;
        }



        if(nums[left]==target){
            arr[0]=left;
            arr[1]=right;
        }else return arr;

        left=0;right=nums.length-1;

        while(left<right){
            mid=(right-left+1)/2+left;
            if(nums[mid]<=target) left=mid;
            else right=mid-1;
        }

        if(nums[right]==target){
            arr[1]=right;
        }



        return arr;

    }
}